<template>
    <div>
        添加用户:
        <van-field label='名称' placeholder="请输入名称" v-model="form.mobile"/>
        <br><br>
        <select v-model="form.role_id">
            <option :value="i.id" v-for="i in rolelist">{{i.name}}</option>
        </select>
            <br><br><br>
        <van-button @click="add">添加</van-button>

        展示角色
        <ul>
            <li v-for="i in rolelist">{{i.name}}
                 
            <router-link :to="{path:'/addresources',query:{'id':i.id}}">配置资源</router-link>
            </li>
           
        </ul>

    

    </div>
</template>

<script>
    export default {
        data(){
            return{
                form:{name:''},
                rolelist:[]
                
            }
        },
        methods:{
            add(){
                this.$axios.post('aduserM',this.form)
                .then(res=>{
                     if(res.data.code==200){
                    alert('添加成功')
                }
                })
               
            },
            get_rolelist(){
                this.$axios.get('roleM')
                .then(res=>{
                    this.rolelist=res.data.list
                })
            },
        },
        mounted(){
            this.get_rolelist()
        },
    }
</script>

<style scoped>

</style>